import java.util.ArrayList;

/**
 * User: kyleolivo
 * Date: 2/9/14
 * Time: 8:26 PM
 */
public class Factors {

    ArrayList<Integer> foundFactors = new ArrayList<Integer>();

    public static void main(String[] args) {
        Factors factors = new Factors();
        factors.generate(1);
        factors.generate(30);
    }

    private void generate(int number) {
        for (int i = 2; i <= number; i++) {
            if (number % i == 0 && unique(i)) {
                foundFactors.add(i);
            }
        }
        System.out.println(foundFactors);
    }

    private boolean unique(int potentialFactor) {
        for (int factor : foundFactors) {
            if (potentialFactor % factor == 0) {
                return false;
            }
        }
        return true;
    }
}
